using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using MeetingRoom.Domain;

namespace MeetingRoom.Data.Implementation
{
    public abstract class ScheduleDAOSupport
    {
        public static List<Schedule> Load(IDataReader dataReader)
        {
            SimpleMeetingRoomTypeQuery meetingRoomTypeQuery = new SimpleMeetingRoomTypeQuery();

            List<Schedule> schedules = new List<Schedule>();

            while (dataReader.Read())
            {
                int meetingRoomTypeId = (int)dataReader["meetingroomtype_id"];
                MeetingRoomType newMeetingRoomType =
                    meetingRoomTypeQuery.GetMeetingRoomTypeById(meetingRoomTypeId);

                DateTime begin = (DateTime)dataReader["begin"];
                DateTime end = (DateTime)dataReader["end"];

                Schedule schedule = new Schedule();
                schedule.Id = (int)dataReader["schedule_id"];
                schedule.Name = (string)dataReader["name"];
                schedule.MeetingRoomType = newMeetingRoomType;
                schedule.Status = (int)dataReader["status"];

                schedules.Add(schedule);
            }

            return schedules;
        }
    }
}
